package com.zxc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zxc.dao.SalPlanMapper;
import com.zxc.entity.SalPlan;
import com.zxc.service.SalPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SalPlanServiceImpl extends ServiceImpl<SalPlanMapper, SalPlan> implements SalPlanService {
    @Autowired
    private SalPlanMapper salPlanMapper;


    @Override
    public List<SalPlan> getSalPlanListByCondition(int skipCounts, Integer pageSize, Integer chcId) {
        List<SalPlan> salPlanList  = salPlanMapper.getSalPlanListByCondition(skipCounts,pageSize,chcId);
        return salPlanList;
    }

    @Override
    public int selectCountSalPlanForMarketing(Integer chcId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("pla_chc_id",chcId);
        int total = salPlanMapper.selectCount(queryWrapper);
        return total;
    }

    @Override
    public int savePlan(SalPlan salPlan) {
        int result = salPlanMapper.insert(salPlan);
        return result;
    }

    @Override
    public int deletePlans(Integer[] plaIds) {
        List plaIdList = new ArrayList();
        for (int id : plaIds){
            plaIdList.add(id);
        }
        int result = salPlanMapper.deleteBatchIds(plaIdList);
        return result;
    }

    @Override
    public int updateSalPlanPlaResult(SalPlan salPlan) {
        int result = salPlanMapper.updateById(salPlan);
        return result;
    }
}
